<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增宠物信息')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-pet-add">
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">宠物名称：</label>
                    <div class="col-sm-8">
                        <input name="name" class="form-control" type="text" required>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">宠物品种：</label>
                    <div class="col-sm-8">
                        <select name="categoryId" id="categoryId" class="form-control" required>
                            <!-- 商品选项将通过 JavaScript 动态填充 -->
                            <option th:each="category:${categoryList}" th:value="${category.id}" th:text="${category.categoryName}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">健康状况：</label>
                    <div class="col-sm-8">
                        <input name="healthStatus" class="form-control" type="text" required>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">宠物年龄：</label>
                    <div class="col-sm-8">
                        <input name="age" class="form-control" type="text" required>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">宠物性别：</label>
                    <div class="col-sm-8">
                        <select name="gender" id="gender" class="form-control" required>
                            <!-- 商品选项将通过 JavaScript 动态填充 -->
                            <option th:each="sex:${sexs}" th:value="${sex.sexKey}" th:text="${sex.sexValue}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">宠物价格：</label>
                    <div class="col-sm-8">
                        <input name="price" class="form-control" type="text" required>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">图片：</label>
                    <!--                 onclick="$.triggerFileInput()"-->
                    <div class="UploadImg">  <!-- 为整个区域添加点击事件 -->
                        <div class="imgList" id="imgList">
                            <!-- 这里用于显示已上传的图片或加载状态 -->
                        </div>
                        <div class="addBtn" id="addBtn">
                            <i class="fa fa-plus"></i>
                        </div>
                    </div>
                    <!--                 onchange="$.uploadImage()"-->
                    <input type="file" id="fileInput" style="display: none;"/>
                    <!-- 隐藏的文件输入元素，并绑定 onchange 事件 -->
                    <input name="imgUrl" id="imgUrl" class="form-control" type="hidden">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "system/pet";
        var uploadUrl = ctx + "common/upload";

        $(document).ready(function () {
            $("#form-pet-add").validate({
                focusCleanup: true
            });

            $.fileUpload.init();
        });


        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-pet-add').serialize());
            }
        }
    </script>
</body>
</html>